#ifndef _IMAGESIZEDLG_H
#define _IMAGESIZEDLG_H

#include  "config.h"

class CImageSizeDlg : public CDialogImpl<CImageSizeDlg>, 
                 public CWinDataExchange<CImageSizeDlg>
{
	
public:
    enum { IDD = IDD_IMAGESIZE };
 
    BEGIN_MSG_MAP(CImageSizeDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
		COMMAND_ID_HANDLER(IDOK, OnOK)
        COMMAND_ID_HANDLER(IDCANCEL, OnCancel)

		//REFLECT_NOTIFICATIONS ()
	END_MSG_MAP()
 
    LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        CenterWindow();
		//Config::g_configFile.read();
		isCustomized = Config::bmpSizeCustomized;
		iW = Config::bmpWidth;
		iH = Config::bmpHeight;

		DoDataExchange(FALSE);
        return TRUE;    // let the system set the focus

    }


    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        EndDialog(IDCANCEL);
        return 0;
    }

	LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
        EndDialog(wID);
        return 0;
    }
	LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
    {
		if(DoDataExchange(TRUE)==0)
		{
			MessageBox(_T("Invalid value of width or height."));
			return 0;
		}

		Config::bmpWidth = isCustomized?iW:BMP_WIDTH;
		Config::bmpHeight = isCustomized?iH:BMP_HEIGHT;
		Config::bmpSizeCustomized = isCustomized;
		//Config::g_configFile.write();
        EndDialog(wID);
        return 0;
    }

	BEGIN_DDX_MAP(CImageSizeDlg)
		DDX_CHECK(IDC_CHECK_CUSTOMIZE, isCustomized)
		DDX_UINT_RANGE(IDC_EDIT_W, iW , 200, 5000)
		DDX_UINT_RANGE(IDC_EDIT_H, iH, 200, 5000)
		//DDX_CONTROL(IDC_COMBOCOLOR, cb_color);
    END_DDX_MAP()

protected:
	bool isCustomized;
	int iW, iH;
public:

};
#endif